package com.controller;

import com.entity.Dept;
import com.service.IDeptService;
import com.until.Result;
import com.vo.Page;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

@RestController
@RequestMapping("dept")
public class DeptController extends BaseController{
    @Resource
    private IDeptService deptService;

    @GetMapping("listAll")
    public Result listAll(){
        return success(deptService.listAll());
    }

    @PostMapping("listByParam")
    public Result listByParam(@RequestBody Page<Dept> page){
        return success(deptService.listByParam(page));
    }

    @GetMapping("getByDeptId")
    public Result getByDeptId(Integer deptId){
        return success(deptService.getByDeptId(deptId));
    }

    @PostMapping("insert")
    public Result insert(@RequestBody Dept dept){
        return success(deptService.insert(dept));
    }

    @PostMapping("update")
    public Result update(@RequestBody Dept dept){
        return success(deptService.update(dept));
    }

    @DeleteMapping("delete")
    public Result delete(Integer deptId){
        return success(deptService.delete(deptId));
    }
}
